package com.boardgame;

import cloud.common.redis.redis.annotation.EnableRedisClient;
import com.boardgame.users.entity.PlayerInfo;
import com.boardgame.users.repository.PlayerInfoRepository;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

@SpringBootApplication(exclude = {SecurityAutoConfiguration.class})
@EnableRedisClient
public class UsersApplication {

    public static void main(String[] args) {
        SpringApplication.run(UsersApplication.class, args);
    }

    @Bean
    public CommandLineRunner demo(PlayerInfoRepository playerRepository) {
        return (args) -> {

            //save a couple of players
            try{
                playerRepository.save(new PlayerInfo("ala", "ala@ala.com", new BCryptPasswordEncoder().encode("ala")));
                playerRepository.save(new PlayerInfo("mary", "mary@mary.com",  new BCryptPasswordEncoder().encode("mary")));


            }
            catch (Exception e){

            }
        };
    }
}

